/******************************************************************************
 *
 * ngcap - network sniffer using raw sockets
 *
 * Author:        cr
 * E-mail:        cr.at.netgarage.org
 * WWW:           http://www.netgarage.org
 * Copyright (C): 2009 by cr
 *
 * This file is part of ngcap.
 *
 * ngcap is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * ngcap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ngcap.  If not, see <http://www.gnu.org/licenses/>.
 *
 *****************************************************************************/

#ifndef _FILTER_HPP_
#define _FILTER_HPP_

#include <string>

class PacketFilter
{
public:
    PacketFilter(const std::string& f);
    void clearFilter();
    void parseFilter();
    void parseProto();
    unsigned short getEthProtocol() const;
    unsigned char getIpProtocol() const;
private:
    enum addressFormat {MAC, IP, IPV6, NONE};
    enum direction {SRC, DST};
    enum paramtype {HOST, NET, PORT};
    std::string filter;
    unsigned short eth_proto;
    unsigned char ip_proto;
    unsigned char src[8];
    unsigned char dst[8];
    unsigned short sport;
    unsigned short dport;
    addressFormat addrf;
    direction dir;
    paramtype type;

};

#endif
